<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <script type="text/javascript" src="/fileManager/js/jquery-1.11.3.min.js"></script>
<title>Insert title here</title>
</head>
<body>
   <a onclick="getdown()">下载</a>
</body>
<script type="text/javascript">
  function getdown(){
	  $.ajax({
			url :"/fileManager/findfile",
			data:{
				strUrl : "http://localhost:8088/fileManager/down"
			},
			type : "GET",
			success : function(data) {
                 var jsonObj = JSON.parse(data);  // JSON.parse(); 方法
                 downfile(jsonObj);
			}
		});
  }
  
  function downfile(jsonObj){
	  $.ajax({
			url :"/fileManager/getFile",
			data:jsonObj,
			 beforeSend: function(request) {
				 var range;
				 var blob=10485760;
				 if((jsonObj.size - jsonObj.start)>=10485760){
			     range= "bytes "+ jsonObj.start + "-"+ (jsonObj.start + blob) + "/" + jsonObj.size;
				 }
				 if(jsonObj.size-jsonObj.start<10485760){
					 range= "bytes "+ jsonObj.start + "-"+ (jsonObj.start + (jsonObj.size-jsonObj.start)) + "/" + jsonObj.size;
				 }
                 request.setRequestHeader("Content-Range", range);
             },
			type : "POST",
			success : function(data) {
                var jsonObj = JSON.parse(data);   
                //downfile(jsonObj);
			}
		});
	  
	  
  }
  
  
</script>
</html>
